home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / sgml / sgml2latex-format.1.3.tar.Z / sgml2latex-format.1.3.tar / bin / biblio < prev    next >
Text File  |  1993-07-14  |  2KB  |  123 lines

  1. #! /bin/sh
  2.  
  3. # synopsis:  biblio filename.sgml
  4. #                 cat filename.sgml | biblio 
  5.  
  6. # author: Tom Gordon 
  7.  
  8. # description: biblio parses and translate an sgml file of the qwertz
  9. # biblio document type into various other formats:
  10.  
  11. #    1) BibTeX
  12. #    2) Refer
  13. #    3) PostScript
  14. #    4) ASCII
  15.  
  16. # The translation is written to standard out.
  17.  
  18. PATH=/vol/sgmlformat/bin:/vol/gnu/bin:$PATH; export PATH
  19. FORMAT=/vol/sgmlformat    
  20. SGMLS=/home/qwertz/local/sgmls/sgmls
  21. SGMLSASP=/home/qwertz/local/sgmls/sgmlsasp
  22.  
  23. SGML_PATH=${SGML_PATH:=$FORMAT/dtd/%N.dtd}
  24. export SGML_PATH
  25. BIN=$FORMAT/bin
  26. LIB=$FORMAT/lib
  27.  
  28. REPDIR=$FORMAT/rep/biblio
  29. TYPE=bibtex      # default format 
  30. AWK=/usr/bin/awk
  31.  
  32. CHECK="no"    # just check SGML syntax
  33.  
  34. cleanup () {
  35.     for i in sgml bib
  36.     do
  37.         if [ -f $$.$i ]
  38.         then
  39.             /bin/rm $$.$i
  40.         fi
  41.     done
  42. }
  43.  
  44. trap 'cleanup; exit 1' 1 2 3 9
  45.  
  46. usage () {
  47. echo "biblio  [-c] [-T (bibtex | refer | grops |  ps | ascii) ] filename[.sgml]";
  48. exit 1 
  49. }
  50.  
  51. case "$1" in
  52.     "-h" | "h" | "help" | "HELP" | "Help" | "-help" ) usage
  53. esac
  54.  
  55. set -- `getopt cT: $*`
  56.  
  57. if [ $? != 0 ]
  58. then
  59.     usage
  60. fi
  61.  
  62. for i in $*
  63. do
  64.         case $i in
  65.        -c)  CHECK="yes"; shift;;
  66.        -T)    TYPE=$2; shift; shift;;
  67.        --)     shift;
  68.         if [ "$1" = "" ] 
  69.         then
  70.             cat 1> $$.sgml  # write standard input to file
  71.             FILE=$$
  72.         else
  73.         FILE=$1
  74.         fi;
  75.             break;;
  76.         esac
  77. done
  78.  
  79. if [ -f $FILE.sgml ] 
  80. then
  81.     FILE=$FILE.sgml
  82. elif [ ! -f $FILE ] 
  83. then
  84.     echo $PROGNAME: cannot find $FILE or $FILE.sgml  >&2
  85.     exit 1
  86. fi
  87.  
  88. map () {
  89.     SGML_PATH=$REPDIR/$2/%N:$SGML_PATH
  90.     export SGML_PATH
  91.     $SGMLS $FILE | $SGMLSASP $REPDIR/$2/mapping
  92. }
  93.  
  94. roff () {
  95.     map $FILE $1 | $AWK -f $FORMAT/lib/refer.post \
  96.     | grefer -sA+E+Q+D1 -en -BX.ip | groff -T $TYPE -me
  97. }
  98.  
  99. if [ $CHECK = "yes" ]
  100. then
  101.     SGML_PATH=$REPDIR/refer/ascii/%N:$SGML_PATH
  102.     export SGML_PATH
  103.     $SGMLS $FILE > /dev/null
  104.     exit 0
  105. fi
  106.     
  107. case $TYPE in
  108.   bibtex ) map $FILE bibtex; break;;
  109.   refer ) map $FILE refer/ascii | $AWK -f $LIB/refer.post ; break;;
  110.   grops ) map $FILE refer/grops | $AWK -f $LIB/refer.post ; break;;
  111.   ps ) map $FILE bibtex > $$.bib; 
  112.        sed "s/BIBFILE/$$/" $LIB/annbib.tex | qtex -b; break;;
  113.   ascii) roff refer/ascii | col -b ; break;;
  114. esac
  115.  
  116. cleanup
  117.  
  118. # end of biblio script
  119.  
  120.  
  121.  
  122.  
  123.